package com.ocom.payconfig.controller;


import com.ocom.common.constant.PayConfigUrl;
import com.ocom.common.entity.payconfig.FeeData;
import com.ocom.common.entity.payconfig.FeeItem;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.common.vo.ComIdVo;
import com.ocom.common.vo.payconfig.FeeDataListVo;
import com.ocom.common.vo.payconfig.FeeItemListVo;
import com.ocom.common.vo.payconfig.PersonRefundVo;
import com.ocom.payconfig.service.FeeDataService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.HashMap;

/**
 * fee_dataController
 *
 * @author junShu
 * @date 2023-08-18 16:57:26
 */
@RestController
public class FeeDataController {

    @Resource
    private FeeDataService feeDataService;

    /**
     * 15.13缴费数据列表（feeData）
     */
    @PostMapping(PayConfigUrl.URL_FeeDetailOnShow)
    public Result feeItemList(@RequestBody FeeDataListVo request) {
//            Page<FeeData> page = feeDataService.selectFeeDataPage(pageNumber, pageSize);
        return feeDataService.feeDataList(request.getComId(),request);
    }

    /**
     * 15.14增加缴费人员（addFeeData）
     */
    @PostMapping(PayConfigUrl.URL_FeeDetailAddPerson)
    public Result addFeeData(@RequestBody FeeDataListVo feeData) {
        return feeDataService.addFeeData(feeData.getComId(), feeData);
    }

    /**
     * 15.15更改缴费金额（updateFeeMoney）
     */
    @PostMapping(PayConfigUrl.URL_FeeDetailModifyAmount)
    public Result updateFeeMoney(@RequestBody FeeDataListVo request) {
        return feeDataService.updateFeeMoney(request.getComId(), request);
    }

    /**
     * 15.16删除缴费人员（removeFeeData）
     *
     * @param
     * @return
     */
    @PostMapping(PayConfigUrl.URL_FeeDetailDeletePerson)
    public Result deleteById(@RequestBody FeeDataListVo request) {
        return feeDataService.removeFeeData(request.getComId(), request);
    }

    /**
     * 15.17增加缴费数据
     *
     * @param request
     * @return
     */
    @PostMapping(PayConfigUrl.URL_addFeeDataByPerson)
    public Result addFeeDataByPerson(@RequestBody FeeDataListVo request) {
        return feeDataService.addFeeDataByPerson(request.getComId(),request);
    }


    @PostMapping(PayConfigUrl.URL_feeDataByPerson)
    public Result feeDataByPerson(@RequestBody FeeDataListVo feeItem){
        HashMap<String, Object>  mapFeeData = feeDataService.feeDataByPerson(feeItem.getComId(),feeItem);
        return  ResultUtil.success(mapFeeData);
    }
    @PostMapping(PayConfigUrl.URL_feeDataPersonRefund)
    public Result personRefund(@Valid @RequestBody PersonRefundVo request){
        return feeDataService.personRefund(request.getComId(),request);
    }
}
